CC := arm-linux-gnueabihf-gcc

INC_DIR := ./include
SRC_DIR := ./src
OBJ_DIR := ./obj
USR_DIR := ./usr

SRC_FILE := $(notdir $(wildcard $(SRC_DIR)/*.c))
USR_FILE := $(notdir $(wildcard $(USR_DIR)/*.c))
OBJ_FILE := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC_FILE) $(USR_FILE))

VPATH := $(USR_DIR) $(SRC_DIR)

TARGET := $(basename $(USR_FILE))		

all:$(TARGET)

$(TARGET):$(OBJ_FILE)
	$(CC) -o $@ $^

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
	$(CC) -c $< -o $@ -I $(INC_DIR)

$(OBJ_DIR)/%.o: $(USR_DIR)/%.c
	$(CC) -c $< -o $@ -I $(INC_DIR)

echo:
	@echo $(SRC_FILE)
	@echo $(USR_FILE)
	@echo $(OBJ_FILE)
	@echo $(TARGET)
clean:
	rm -f $(OBJ_FILE)
	rm -f $(TARGET)